'''
Created on 12/12/2011

@author: Marina
'''

class Page:
    '''
    classdocs
    '''

    def __init__(self, nombrePrograma, pageSize, disco, numeroPagina):
        '''
        Constructor
        '''
        self.estaEnMemoria=False
        self.marco = None
        self.nombrePrograma = nombrePrograma
        self.pageSize = pageSize
        self.disco = disco
        self.used = 0
        self.numeroPagina = numeroPagina

    def readPageFromDisc(self):
        programa = self.disco.read(self.nombrePrograma)
        codigo = []
        
        
        resto = programa.programSize % self.pageSize
        cantPaginas = programa.programSize // self.pageSize #son la cantidad de paginas para asignar a un programa
        if resto is not 0:
            cantPaginas+=1
        
        
        
        start = self.numeroPagina % cantPaginas
        
        indice = start * self.pageSize
        
        variable = 0
        
        #for linea in programa.sourceCode:
        while variable < self.pageSize and indice < programa.programSize:
            codigo.append(programa.sourceCode[indice])
            indice += 1
            variable += 1
                
        return codigo
    